package com.walterweimod.auxiliary_attributes.event.hooks;

import com.walterweimod.auxiliary_attributes.event.new_event.LivingAbsorptionChangeEvent;
import com.walterweimod.auxiliary_attributes.event.new_event.LivingAfterDamageEvent;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.LivingEntity;
import net.minecraftforge.common.MinecraftForge;

public class ModForgeHooks {
    private ModForgeHooks(){}

    public static void afterLivingDamage(LivingEntity livingEntity,
                                     DamageSource damageSource,
                                     float amount) {
        LivingAfterDamageEvent event = new LivingAfterDamageEvent(
                livingEntity, damageSource, amount
        );

        MinecraftForge.EVENT_BUS.post(event);
    }

    public static float onLivingAbsorptionChange(LivingEntity livingEntity,
                                         float amount) {
        LivingAbsorptionChangeEvent event = new LivingAbsorptionChangeEvent(
                livingEntity, amount
        );

        return MinecraftForge.EVENT_BUS.post(event) ?
                livingEntity.getAbsorptionAmount() : event.getAmount();
    }
}
